package ma30082014;
/*
 Ashish and Binary Matrix
Max. Score 100
Pulkit is really good at maths. Recently, he came to know about a problem on matrices. Amazed by the problem he got, he asked Ashish the same problem. Ashish also being good at maths solved the problem within 5 minutes. Now, its your time to solve the problem.

You will be given n*m binary matrix. You need to tell if it is possible to delete a column such that after deleting that column, rows of the matrix will be unique. If yes than print "Yes" else print "No".

[Input]
First line contains an integer t denoting no.of test cases. 
Next line contains 2 integers n and m denoting no.of rows and columns.
Next n line contains binary string of length m each.

[Output]
For each test case output "Yes" or "No".

[Constraints]
1<=t<=100
1<=n<=1000
2<=m<=1000

Sample Input (Plaintext Link)
2
3 3
101
000
100
2 2
11
11

Sample Output (Plaintext Link)
Yes
No
 */
import java.util.Scanner;

public class Solution3 {

	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		int t  = s.nextInt();
		while(t-- > 0) {
			int n = s.nextInt();
			int m = s.nextInt();
			String[] rows = new String[n];
			for (int i = 0; i < n; i++) {
				rows[i] = s.next();
			}
			boolean isUnique = true;
			for (int i = 0; i < m; i++) { //col
				boolean isUnique1 = true;
				for (int j = 0; j < n; j++) {
					String str = rows[j];
					char[] charArray = str.toCharArray();
					charArray[i] = '1';
					str = new String(charArray);
					
					boolean isUnique2 = true;
					for (int k = j+1; k < n; k++) {
						String str2 = rows[k];
						char[] charArray2 = str2.toCharArray();
						charArray2[i] = '1';
						str2 = new String(charArray2);
						System.out.println("str=" + str + " str2=" + str2);
						if(str.compareTo(str2) == 0) {
							isUnique2 = false;
							break;
						}
					}
					isUnique1 = isUnique2;
					if(!isUnique2) {
						break;
					}
				}
				isUnique = isUnique1;
				if(!isUnique1) {
					break;
				}
			}
			if(isUnique) {
				System.out.println("Yes");
			} else {
				System.out.println("No");
			}
		}
		s.close();
	}

}
